<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>项目投标文件查看</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            font-family: "Microsoft YaHei", sans-serif;
            background-color: #f5f5f5;
            color: #333;
        }
        .container {
            width: 100%;
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 0;
            border-bottom: 1px solid #ddd;
            margin-bottom: 20px;
        }
        .header h1 {
            font-size: 20px;
            color: #333;
        }
        .user-info {
            display: flex;
            align-items: center;
        }
        .user-info span {
            margin-right: 10px;
        }
        .user-info a {
            color: #1890ff;
            text-decoration: none;
        }
        .search-bar {
            margin-bottom: 20px;
            display: flex;
            align-items: center;
        }
        .search-input {
            flex: 1;
            padding: 8px 12px;
            border: 1px solid #d9d9d9;
            border-radius: 4px;
            margin-right: 10px;
        }
        .search-btn {
            background-color: #1890ff;
            color: white;
            border: none;
            padding: 8px 16px;
            border-radius: 4px;
            cursor: pointer;
        }
        .search-btn:hover {
            background-color: #40a9ff;
        }
        .project-table {
            width: 100%;
            border-collapse: collapse;
            background-color: #fff;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        }
        .project-table th, .project-table td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid #e8e8e8;
        }
        .project-table th {
            background-color: #fafafa;
            font-weight: 500;
        }
        .project-table tr:hover {
            background-color: #f5f5f5;
        }
        .project-table tr.selected {
            background-color: #e6f7ff;
        }
        .supplier-container {
            margin-top: 20px;
            background-color: #fff;
            border-radius: 4px;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
            padding: 15px;
            display: none;
        }
        .supplier-title {
            font-size: 16px;
            margin-bottom: 15px;
            padding-bottom: 10px;
            border-bottom: 1px solid #e8e8e8;
        }
        .supplier-list {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
            gap: 15px;
        }
        .supplier-card {
            background-color: #fafafa;
            border: 1px solid #e8e8e8;
            border-radius: 4px;
            padding: 15px;
            cursor: pointer;
            transition: all 0.3s;
        }
        .supplier-card:hover {
            border-color: #1890ff;
            box-shadow: 0 2px 8px rgba(24, 144, 255, 0.15);
        }
        .supplier-name {
            font-weight: 500;
            margin-bottom: 5px;
        }
        .supplier-info {
            color: #666;
            font-size: 14px;
        }
        .pagination {
            display: flex;
            justify-content: flex-end;
            margin-top: 20px;
        }
        .pagination button {
            background-color: #fff;
            border: 1px solid #d9d9d9;
            padding: 5px 10px;
            margin: 0 5px;
            cursor: pointer;
        }
        .pagination button.active {
            background-color: #1890ff;
            color: white;
            border-color: #1890ff;
        }
        .pagination button:hover:not(.active) {
            border-color: #1890ff;
            color: #1890ff;
        }
        .document-viewer {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }
        .document-container {
            background-color: white;
            width: 80%;
            height: 80%;
            border-radius: 4px;
            overflow: hidden;
            display: flex;
            flex-direction: column;
        }
        .document-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 20px;
            background-color: #f5f5f5;
            border-bottom: 1px solid #e8e8e8;
        }
        .document-title {
            font-size: 16px;
            font-weight: 500;
        }
        .close-btn {
            background: none;
            border: none;
            font-size: 20px;
            cursor: pointer;
            color: #666;
        }
        .document-content {
            flex: 1;
            padding: 20px;
            overflow: auto;
        }
        /* 按钮组样式 */
        .btn-group {
            display: flex;
            gap: 10px;
            margin-bottom: 15px;
        }
        .btn {
            padding: 8px 16px;
            border-radius: 4px;
            font-size: 14px;
            cursor: pointer;
            border: none;
            transition: all 0.3s;
            display: flex;
            align-items: center;
            gap: 5px;
        }
        .btn-primary {
            background-color: #1890ff;
            color: #fff;
        }
        .btn-primary:hover {
            background-color: #40a9ff;
        }
        .btn-default {
            background-color: #f5f5f5;
            color: #333;
            border: 1px solid #d9d9d9;
        }
        .btn-default:hover {
            background-color: #e8e8e8;
        }
        .btn-disabled {
            background-color: #f5f5f5;
            color: #bfbfbf;
            cursor: not-allowed;
        }
        /* 模态框样式 */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(0, 0, 0, 0.5);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 1000;
            visibility: hidden;
            opacity: 0;
            transition: visibility 0s linear 0.25s, opacity 0.25s 0s;
        }
        .modal-overlay.active {
            visibility: visible;
            opacity: 1;
            transition-delay: 0s;
        }
        .modal-content {
            background-color: white;
            border-radius: 4px;
            width: 500px;
            max-width: 90%;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
        }
        .modal-header {
            padding: 15px 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid #e8e8e8;
        }
        .modal-title {
            font-size: 16px;
            font-weight: 500;
            color: #333;
        }
        .modal-close {
            background: none;
            border: none;
            font-size: 20px;
            cursor: pointer;
            color: #999;
        }
        .modal-close:hover {
            color: #333;
        }
        .modal-body {
            padding: 20px;
        }
        .modal-footer {
            padding: 15px 20px;
            border-top: 1px solid #e8e8e8;
            display: flex;
            justify-content: flex-end;
            gap: 10px;
        }
        .reviewer-list {
            max-height: 200px;
            overflow-y: auto;
            margin-top: 15px;
            border: 1px solid #e8e8e8;
            border-radius: 4px;
        }
        .reviewer-item {
            padding: 10px 15px;
            display: flex;
            align-items: center;
            border-bottom: 1px solid #f0f0f0;
        }
        .reviewer-item:last-child {
            border-bottom: none;
        }
        .reviewer-checkbox {
            margin-right: 10px;
        }
        .project-status {
            margin-bottom: 15px;
            font-size: 14px;
            color: #666;
        }
        .reviewer-search {
            width: 100%;
            padding: 8px 12px;
            border: 1px solid #d9d9d9;
            border-radius: 4px;
            margin-bottom: 10px;
            font-size: 14px;
        }
        .reviewer-search:focus {
            outline: none;
            border-color: #40a9ff;
            box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>项目投标文件查看</h1>
        </div>
        
        <div class="search-bar">
            <input type="text" class="search-input" placeholder="项目名称/项目编号/联系人">
            <button class="search-btn">搜索</button>
        </div>
        
        <!-- 添加按钮组 -->
        <div class="btn-group">
            <button class="btn btn-primary" id="addBidEvaluatorBtn">
                <i class="fas fa-user-plus"></i> 添加评标人
            </button>
        </div>
        
        <table class="project-table">
            <thead>
                <tr>
                    <th>项目编号</th>
                    <th>项目名称</th>
                    <th>采购单位</th>
                    <th>联系人</th>
                    <th>联系方式</th>
                    <th>创建时间</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <tr data-project-id="1">
                    <td>P2022001</td>
                    <td>信息化系统建设项目</td>
                    <td>XX学院</td>
                    <td>张三</td>
                    <td>13800138000</td>
                    <td>2022-01-14</td>
                    <td>已结束</td>
                    <td><button class="view-btn">查看</button></td>
                </tr>
                <tr data-project-id="2">
                    <td>P2022002</td>
                    <td>校园网络升级项目</td>
                    <td>XX大学</td>
                    <td>李四</td>
                    <td>13900139000</td>
                    <td>2022-01-14</td>
                    <td>未结束</td>
                    <td><button class="view-btn">查看</button></td>
                </tr>
                <tr data-project-id="3">
                    <td>P2020001</td>
                    <td>实验室设备采购</td>
                    <td>XX研究所</td>
                    <td>王五</td>
                    <td>13700137000</td>
                    <td>2020-09-21</td>
                    <td>已结束</td>
                    <td><button class="view-btn">查看</button></td>
                </tr>
                <tr data-project-id="4">
                    <td>P2024001</td>
                    <td>图书馆资源建设</td>
                    <td>XX图书馆</td>
                    <td>赵六</td>
                    <td>13600136000</td>
                    <td>2024-02-26</td>
                    <td>进行中</td>
                    <td><button class="view-btn">查看</button></td>
                </tr>
                <tr data-project-id="5">
                    <td>P2020002</td>
                    <td>食堂设备更新</td>
                    <td>XX后勤处</td>
                    <td>钱七</td>
                    <td>13500135000</td>
                    <td>2020-09-21</td>
                    <td>已结束</td>
                    <td><button class="view-btn">查看</button></td>
                </tr>
            </tbody>
        </table>
        
        <div class="pagination">
            <button>上一页</button>
            <button class="active">1</button>
            <button>2</button>
            <button>3</button>
            <button>下一页</button>
        </div>
        
        <div class="supplier-container" id="supplierContainer">
            <h2 class="supplier-title">项目供应商列表</h2>
            <div class="supplier-list" id="supplierList">
                <!-- 供应商列表将通过JavaScript动态生成 -->
            </div>
        </div>
    </div>
    
    <div class="document-viewer" id="documentViewer">
        <div class="document-container">
            <div class="document-header">
                <div class="document-title" id="documentTitle">投标文件</div>
                <button class="close-btn" id="closeDocumentBtn">&times;</button>
            </div>
            <div class="document-content" id="documentContent">
                <!-- 文档内容将通过JavaScript动态生成 -->
            </div>
        </div>
    </div>

    <!-- 添加评标人模态框 -->
    <div class="modal-overlay" id="addBidEvaluatorModal">
        <div class="modal-content">
            <div class="modal-header">
                <h3 class="modal-title">添加评标人</h3>
                <button class="modal-close" id="closeBidEvaluatorModal">&times;</button>
            </div>
            <div class="modal-body">
                <div class="project-status">项目状态：待评标</div>
                <div>
                    <input type="text" class="reviewer-search" placeholder="评标人姓名搜索" id="bidEvaluatorSearch">
                    <div class="reviewer-list">
                        <div class="reviewer-item">
                            <input type="checkbox" class="reviewer-checkbox" id="bidEvaluator1">
                            <label for="bidEvaluator1">赵专家</label>
                        </div>
                        <div class="reviewer-item">
                            <input type="checkbox" class="reviewer-checkbox" id="bidEvaluator2">
                            <label for="bidEvaluator2">钱专家</label>
                        </div>
                        <div class="reviewer-item">
                            <input type="checkbox" class="reviewer-checkbox" id="bidEvaluator3">
                            <label for="bidEvaluator3">孙专家</label>
                        </div>
                        <div class="reviewer-item">
                            <input type="checkbox" class="reviewer-checkbox" id="bidEvaluator4">
                            <label for="bidEvaluator4">李专家</label>
                        </div>
                        <div class="reviewer-item">
                            <input type="checkbox" class="reviewer-checkbox" id="bidEvaluator5">
                            <label for="bidEvaluator5">周专家</label>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" id="cancelAddBidEvaluator">取消</button>
                <button class="btn btn-primary" id="submitAddBidEvaluator">提交</button>
            </div>
        </div>
    </div>

    <script>
        // 模拟数据
        const projectData = {
            "1": {
                name: "信息化系统建设项目",
                suppliers: [
                    { id: "s1", name: "科技有限公司A", bidTime: "2022-01-10 14:30:25", documents: ["技术方案.pdf", "商务报价.xlsx"] },
                    { id: "s2", name: "软件开发公司B", bidTime: "2022-01-10 15:45:12", documents: ["技术方案.pdf", "商务报价.xlsx"] },
                    { id: "s3", name: "系统集成公司C", bidTime: "2022-01-10 16:20:05", documents: ["技术方案.pdf", "商务报价.xlsx"] }
                ]
            },
            "2": {
                name: "校园网络升级项目",
                suppliers: [
                    { id: "s4", name: "网络设备公司D", bidTime: "2022-01-08 09:15:30", documents: ["技术方案.pdf", "商务报价.xlsx"] },
                    { id: "s5", name: "通信技术公司E", bidTime: "2022-01-08 10:30:45", documents: ["技术方案.pdf", "商务报价.xlsx"] }
                ]
            },
            "3": {
                name: "实验室设备采购",
                suppliers: [
                    { id: "s6", name: "实验设备公司F", bidTime: "2020-09-15 13:20:10", documents: ["技术方案.pdf", "商务报价.xlsx"] },
                    { id: "s7", name: "科学仪器公司G", bidTime: "2020-09-15 14:05:22", documents: ["技术方案.pdf", "商务报价.xlsx"] },
                    { id: "s8", name: "实验室解决方案公司H", bidTime: "2020-09-15 16:40:18", documents: ["技术方案.pdf", "商务报价.xlsx"] }
                ]
            },
            "4": {
                name: "图书馆资源建设",
                suppliers: [
                    { id: "s9", name: "出版社I", bidTime: "2024-02-20 10:10:10", documents: ["技术方案.pdf", "商务报价.xlsx"] },
                    { id: "s10", name: "数字资源公司J", bidTime: "2024-02-20 11:25:30", documents: ["技术方案.pdf", "商务报价.xlsx"] }
                ]
            },
            "5": {
                name: "食堂设备更新",
                suppliers: [
                    { id: "s11", name: "厨房设备公司K", bidTime: "2020-09-10 09:30:15", documents: ["技术方案.pdf", "商务报价.xlsx"] },
                    { id: "s12", name: "餐饮设备公司L", bidTime: "2020-09-10 10:45:20", documents: ["技术方案.pdf", "商务报价.xlsx"] }
                ]
            }
        };

        // 获取DOM元素
        const viewButtons = document.querySelectorAll('.view-btn');
        const supplierContainer = document.getElementById('supplierContainer');
        const supplierList = document.getElementById('supplierList');
        const documentViewer = document.getElementById('documentViewer');
        const documentTitle = document.getElementById('documentTitle');
        const documentContent = document.getElementById('documentContent');
        const closeDocumentBtn = document.getElementById('closeDocumentBtn');
        
        // 为查看按钮添加点击事件
        viewButtons.forEach(button => {
            button.addEventListener('click', function() {
                const projectRow = this.closest('tr');
                const projectId = projectRow.dataset.projectId;
                
                // 移除之前选中的行的样式
                document.querySelectorAll('.project-table tr.selected').forEach(row => {
                    row.classList.remove('selected');
                });
                
                // 添加选中样式
                projectRow.classList.add('selected');
                
                // 显示供应商列表
                showSuppliers(projectId);
            });
        });
        
        // 显示供应商列表
        function showSuppliers(projectId) {
            const project = projectData[projectId];
            if (!project) return;
            
            // 清空供应商列表
            supplierList.innerHTML = '';
            
            // 添加供应商卡片
            project.suppliers.forEach(supplier => {
                const supplierCard = document.createElement('div');
                supplierCard.className = 'supplier-card';
                supplierCard.dataset.supplierId = supplier.id;
                
                supplierCard.innerHTML = `
                    <div class="supplier-name">${supplier.name}</div>
                    <div class="supplier-info">投标时间: ${supplier.bidTime}</div>
                    <div class="supplier-info">文档数量: ${supplier.documents.length}</div>
                `;
                
                // 添加点击事件，显示投标文件
                supplierCard.addEventListener('click', function() {
                    showBidDocuments(project.name, supplier);
                });
                
                supplierList.appendChild(supplierCard);
            });
            
            // 显示供应商容器
            supplierContainer.style.display = 'block';
        }
        
        // 显示投标文件
        function showBidDocuments(projectName, supplier) {
            // 设置文档标题
            documentTitle.textContent = `${projectName} - ${supplier.name} 投标文件`;
            
            // 生成文档内容
            let content = `<h3>供应商: ${supplier.name}</h3>`;
            content += `<p>投标时间: ${supplier.bidTime}</p>`;
            content += `<h4>文档列表:</h4>`;
            content += `<ul>`;
            supplier.documents.forEach(doc => {
                content += `<li><a href="#">${doc}</a></li>`;
            });
            content += `</ul>`;
            content += `<div style="margin-top: 20px; padding: 15px; background-color: #f9f9f9; border: 1px solid #e8e8e8;">
                <h4>技术方案摘要</h4>
                <p>这里是供应商提供的技术方案摘要内容，实际项目中应显示真实的文档内容或预览。</p>
                <p>可以通过集成文档预览组件来实现PDF、Word、Excel等文档的在线预览功能。</p>
            </div>`;
            
            // 设置文档内容
            documentContent.innerHTML = content;
            
            // 显示文档查看器
            documentViewer.style.display = 'flex';
        }
        
        // 关闭文档查看器
        closeDocumentBtn.addEventListener('click', function() {
            documentViewer.style.display = 'none';
        });
        
        // 点击文档查看器背景关闭
        documentViewer.addEventListener('click', function(e) {
            if (e.target === documentViewer) {
                documentViewer.style.display = 'none';
            }
        });
        
        // 搜索功能
        const searchInput = document.querySelector('.search-input');
        const searchBtn = document.querySelector('.search-btn');
        
        searchBtn.addEventListener('click', function() {
            const searchTerm = searchInput.value.toLowerCase();
            const rows = document.querySelectorAll('.project-table tbody tr');
            
            rows.forEach(row => {
                const text = row.textContent.toLowerCase();
                if (text.includes(searchTerm)) {
                    row.style.display = '';
                } else {
                    row.style.display = 'none';
                }
            });
        });

        // 点击页面空白处取消选择
        document.addEventListener('click', function(e) {
            if (!e.target.closest('.project-table') && 
                !e.target.closest('#addBidEvaluatorBtn') &&
                !e.target.closest('#addBidEvaluatorModal')) {
                
                document.querySelectorAll('.project-table tr.selected').forEach(row => {
                    row.classList.remove('selected');
                });
            }
        });
        
        // 添加评标人模态框相关函数
        function showAddBidEvaluatorModal() {
            document.getElementById('addBidEvaluatorModal').classList.add('active');
        }

        function hideAddBidEvaluatorModal() {
            document.getElementById('addBidEvaluatorModal').classList.remove('active');
        }

        // 为添加评标人按钮添加点击事件
        document.getElementById('addBidEvaluatorBtn').addEventListener('click', function() {
            const selectedRow = document.querySelector('.project-table tr.selected');
            if (!selectedRow) {
                alert('请先选择一个项目');
                return;
            }
            showAddBidEvaluatorModal();
        });

        // 为模态框关闭按钮添加点击事件
        document.getElementById('closeBidEvaluatorModal').addEventListener('click', hideAddBidEvaluatorModal);
        document.getElementById('cancelAddBidEvaluator').addEventListener('click', hideAddBidEvaluatorModal);

        // 评标人搜索功能
        document.getElementById('bidEvaluatorSearch').addEventListener('input', function () {
            const searchText = this.value.toLowerCase();
            const evaluatorItems = document.querySelectorAll('#addBidEvaluatorModal .reviewer-item');

            evaluatorItems.forEach(item => {
                const evaluatorName = item.querySelector('label').textContent.toLowerCase();
                if (evaluatorName.includes(searchText)) {
                    item.style.display = '';
                } else {
                    item.style.display = 'none';
                }
            });
        });

        // 提交添加评标人
        document.getElementById('submitAddBidEvaluator').addEventListener('click', function () {
            // 获取选中的评标人
            const checkedEvaluators = document.querySelectorAll('#addBidEvaluatorModal .reviewer-checkbox:checked');
            if (checkedEvaluators.length === 0) {
                alert('请选择至少一名评标人');
                return;
            }

            const selectedRow = document.querySelector('.project-table tr.selected');
            if (selectedRow) {
                const projectId = selectedRow.dataset.projectId;
                const projectName = selectedRow.cells[1].textContent;
                
                // 这里可以添加提交到后端的代码
                // 模拟数据存储，实际项目中应该发送到服务器
                const evaluators = Array.from(checkedEvaluators).map(checkbox => {
                    return checkbox.nextElementSibling.textContent;
                });
                
                // 在本地存储中保存评标人信息
                const projectEvaluators = JSON.parse(localStorage.getItem('projectEvaluators') || '{}');
                projectEvaluators[projectId] = evaluators;
                localStorage.setItem('projectEvaluators', JSON.stringify(projectEvaluators));

                alert(`已成功为项目"${projectName}"添加${checkedEvaluators.length}名评标人`);
                hideAddBidEvaluatorModal();
            }
        });
    </script>
</body>
</html>
